<template>
<div class="singleLogin"><img src="../../assets/login.gif" alt=""></div>
</template>

<script>
export default {
  name: "singleLogin",
  mounted() {
    this.goLogin()
  },
  methods:{
    goLogin(){
      let query = this.$route.query
      this.$api.loginSSO({code:query.code}).then(res=>{
        this.$store.dispatch("setIsLogin", true);
        sessionStorage.setItem("token", res.token);
        this.$api.getUser({}).then((res) => {
          this.$store.dispatch("setUserInfo", res.data);
          localStorage.setItem("userInfo", JSON.stringify(res.data));
          this.$router.push({name:'home'})
        });
      }).catch(err=>{
      })
    },
  },
}
</script>

<style scoped
lang="less">
.singleLogin{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  img{
    width: 30%;
    //height: 30%;
  }
}
</style>